<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/grsun" prefix="grsun"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<meta name="description" content="Mailbox with some customizations as described in docs" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<%@ include file="/include/main_include.jsp"%>
<%@ include file="/include/form_include.jsp"%>
<link type='text/css' rel='stylesheet' href='${path}/static/myjs/information/home/css/balance.css' />
</head>
<body>
		<div id="main">
			<div id="bal">
				<p>
					<span>到账银行卡</span>
					<span>${agent.bank}（${agent.bankCard }）</span>
				</p>
				<!--<span><i>2017-03-20</i>&nbsp;&nbsp;到&nbsp;&nbsp;<i>2017-04-20</i></span>-->
				<p>总营收</p>
				<div>
					<!-- 				￥&nbsp;&nbsp; -->
					<i>￥${agent.balance }</i>
				</div>
			</div>
			<div class="part_two">
				<p>提现扣除</p>
				<span>银联转账手续费：2元/笔</span>
				<span>微信支付宝提现手续费：<i>${wxFee }</i>元<i> </i></span>
				<p>
					最终到账
					<i>￥${trueAccount }</i>
				</p>
				<div>
					<input type="text" name="CODE"  id="code"/>
					<button id="getCodeBtn">获取验证码</button>
				</div>
				<button id="submitBtn">提现</button>
			</div>
		</div>
	<script type="text/javascript">
		$(function() {
			var balance = '${agent.balance }';
			 
			 $('#submitBtn').on('click', function() {
		        	if (  balance<=0) {
		            	layer.msg('余额不足,不能提现');
		            	return; 
		            }
		        	
		        	var code=$("#code").val();
		        	if(code==''){
		        		layer.msg('请输入验证码');
		            	return; 
		        	}
		        	 $.get(rootpath + '/hhWithdrawAgent/agentWithdraw.do?code='+code, function(data, status) {
		        		 if(data.code==0){
			        		 alert("提现成功");
			        		 var index = parent.layer.getFrameIndex(window.name);
			        		 parent.layer.close(index);
		        		 }else{
		        			 layer.msg(data.msg);
		        		 }
		        	 });
		        });

		        $('#getCodeBtn').on('click', function() {
		            var getCodeBtn = $(this);
		            if (  balance<=0) {
		            	layer.msg('余额不足,不能提现');
		            	return; 
		            }
		            
		            $(getCodeBtn).attr("disabled", true);
		             
		            $.get(rootpath + '/hhWithdrawAgent/sendCode.do?', function(data, status) {
		                if (data.code==0) {
		                        settime(getCodeBtn);
		                        layer.msg('验证码已发送');
		                }else {
		                	 $(getCodeBtn).attr("disabled", false);
		                        layer.msg('验证码发送失败,'+data.msg)
		                }
		            });
		            return false;
		        });

		        var countdown = 60;
		        function settime(obj) {
		            if (countdown == 0) {
		            	$(getCodeBtn).attr("disabled", false);
		                $(getCodeBtn).html("获取验证码");
		                countdown = 60;
		                return;
		            } else {
		                $(obj).attr("disabled", true);
		                $(obj).html("重新发送(" + countdown + ")");
		                countdown--;
		            }
		            setTimeout(function() {
		                settime(obj)
		            }, 1000)
		        }

		});
	</script>
</body>
</html>
